<template>
  <div id="app">
    <h1>根组件</h1>
    <input type="text" :value="$store.state.num" @input="mNum">
    <add-item></add-item>
    <hr>
    <sub-item></sub-item>
  </div>
</template>

<script>
import AddItem from './components/AddItem.vue'
import SubItem from './components/SubItem.vue'
import { mapMutations } from 'vuex'

export default {
  name: 'app',
  // 使用vuex中的数据
  components: {
    AddItem,
    SubItem
  },
  methods: {
    ...mapMutations(['mNum']),
    // mInput(e){
    //   console.log(e.target.value)
    //   this.$store.commit('mNum',e.target.value)
    // }
  }
}
</script>

<style>
#app {
  width: 300px;
  margin: 20px auto;
  border:1px solid #ccc;
  padding:4px;
}
</style>
